//
//  NetworkTool.h
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/12.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>

@interface NetworkTool : AFHTTPSessionManager

/** 成功回调 */
typedef void(^SuccessCompletedBlock)(id responseObject);

/** 失败回调 */
typedef void(^FailureCompletedBlock)(NSError *error);


/** 网络回调 */
typedef void(^ReachabilityIsOKBlock)(BOOL isReachability);


/** 单例 实例化 */
+ (instancetype)shareManager;

/** 初始化 */
+(instancetype)manager;

/** 检测网络 */
- (BOOL)isReachableByAFN;


/** Reachability 自定义的 GET 请求 */
- (void)GET_RequestWithUrlString:(NSString *)urlString
                          parmas:(NSDictionary *)params
                   successBloock:(SuccessCompletedBlock)success
                    failureBlock:(FailureCompletedBlock)failure
               ReachabilityBlock:(ReachabilityIsOKBlock)isReachable;


/** Reachability 自定义的 POST 请求 */
- (void)POST_RequestWithUrlString:(NSString *)urlString
                           parmas:(NSDictionary *)params
                    successBloock:(SuccessCompletedBlock)success
                     failureBlock:(FailureCompletedBlock)failure
                ReachabilityBlock:(ReachabilityIsOKBlock)isReachable;


/**  ML 自定义的 POST 请求 */
- (void)POST_RequestWithUrlString:(NSString *)urlString
                           parmas:(NSDictionary *)params
                    successBloock:(SuccessCompletedBlock)success
                     failureBlock:(FailureCompletedBlock)failure;

/**
 *  POST方法
 */
-(void)POST:(NSString*)url Param:(NSDictionary*)param andWaitStr:(NSString*)waitString waitView:(UIView*)waitView success:(void(^_Nonnull)(id _Nullable responseObject))success andFailure:(void(^_Nonnull)(NSError * _Nonnull error))errorBlock;


/**
 *  POST方法
 */
-(void)GET:(NSString*)url Param:(NSDictionary*)param andWaitStr:(NSString*)waitString waitView:(UIView*)waitView success:(void(^_Nonnull)(id _Nullable responseObject))success andFailure:(void(^_Nonnull)(NSError * _Nonnull error))errorBlock;
-(void)POST:(NSString*)url Param:(NSDictionary*)param File:(NSData*)file fileKey:(NSString*)fileKey andFileName:(NSString*)fileName andWaitStr:(NSString*)waitString waitView:(UIView*)waitView success:(void(^)(id _Nullable responseObject))success andFailure:(void(^)(NSError * _Nonnull error))errorBlock;
-(void)POSTJson:(NSString *)url Param:(NSDictionary *)param andWaitStr:(NSString *)waitString waitView:(UIView *)waitView success:(void (^)(id _Nullable))success andFailure:(void (^)(NSError * _Nonnull))errorBlock;
@end
